package com.cloud.base.bean;

import com.cloud.base.ExceptionConstant;
import lombok.Data;

import java.text.MessageFormat;

import static com.cloud.base.ExceptionConstant.REQUEST_SUCCESS;

@Data
public class CloudResponse<T> {

    private Integer code;
    private String msg;

    private T data;

    public CloudResponse(T data) {
        this.data = data;
        this.code = REQUEST_SUCCESS.getCode();
        this.msg = REQUEST_SUCCESS.getMsg();
    }

    public CloudResponse(ExceptionConstant constant, String... msgs) {
        this.code = constant.getCode();
        this.msg = MessageFormat.format(constant.getMsg(), msgs);
    }
}
